package com.mezz.bones.framework.websocket.config;

import com.mezz.bones.framework.websocket.handler.DefaultWebSocketMessageHandler;
import com.mezz.bones.framework.websocket.handler.WebSocketMessageHandler;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.socket.server.standard.ServerEndpointExporter;

@Configuration
public class WebSocketConfig {

    /**
     * 开启ws端点服务
     */
    @Bean
    public ServerEndpointExporter serverEndpointExporter() {
        return new ServerEndpointExporter();
    }

    @Bean
    @ConditionalOnMissingBean(WebSocketMessageHandler.class)
    public WebSocketMessageHandler defaultWebSocketMessageHandler() {
        return new DefaultWebSocketMessageHandler();
    }
}